package com.dong.ioc.annotation;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.convert.ConversionService;
import org.springframework.format.support.DefaultFormattingConversionService;

/**
 * description
 *
 * @author Administrator 2021/09/02 10:32
 */
@Configuration
@PropertySource("classpath:application.properties")
public class AppConfiguration {

    @Bean
    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(){
        final PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
//        propertySourcesPlaceholderConfigurer.setPlaceholderSuffix(")");
//        propertySourcesPlaceholderConfigurer.setPlaceholderPrefix("!(");
//        propertySourcesPlaceholderConfigurer.setValueSeparator("-");
        return propertySourcesPlaceholderConfigurer;
    }

    @Bean
    public ConversionService conversionService(){
        DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
        conversionService.addConverter(new MyConverter());
        return conversionService;
    }

    @Bean
    public User user(){
        User user = new User();
        user.setUsername("jerry");
        return user;
    }
}
